package com.idealighter.game.player.service.convert;

import com.idealighter.game.core.convert.DateLongValueConvert;
import com.idealighter.game.core.convert.LongAtomicLongConvert;
import com.idealighter.game.player.service.bo.PlayerBo;
import com.idealighter.game.player.service.bo.PlayerRankBo;
import com.idealighter.game.server.db.datadb.generate.domain.PlayerGameInfoDomainWithBLOBs;
import com.idealighter.game.server.db.datadb.generate.domain.PlayerInfoDomain;
import com.idealighter.game.server.db.datadb.generate.domain.PlayerMainDomain;
import com.idealighter.game.server.db.datadb.generate.domain.PlayerSafeInfoDomain;
import com.idealighter.game.server.db.datadb.generate.domain.PlayerStatusRecordDomain;
import com.idealighter.game.server.db.datadb.generate.domain.PlayerVipDomain;
import com.idealighter.game.server.db.datadb.generate.domain.RoomCardPlayerRoundCountDomain;
import java.util.List;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

@Mapper(uses = {DateLongValueConvert.class, LongAtomicLongConvert.class})
public interface PlayerBoConvert {

  PlayerBoConvert INSTANCE = Mappers.getMapper(PlayerBoConvert.class);

  @Mapping(target = "id", source = "mainDomain.id")
  @Mapping(target = "roundCount", expression = "java(roundCount==null?0:roundCount.getCount())")
  PlayerBo toPlayerBo(PlayerMainDomain mainDomain, PlayerInfoDomain playerInfoDomain,
      PlayerGameInfoDomainWithBLOBs playerGameInfoDomain,
      PlayerSafeInfoDomain playerSafeInfoDomain, PlayerVipDomain playerVipDomain,
      PlayerStatusRecordDomain playerStatusRecordDomain,
      RoomCardPlayerRoundCountDomain roundCount);

  PlayerMainDomain toPlayerMainDomain(PlayerBo bo);

  @Mapping(target = "playerId", source = "id")
  @Mapping(target = "id", ignore = true)
  PlayerInfoDomain toPlayerInfoDomain(PlayerBo bo);

  @Mapping(target = "playerId", source = "id")
  @Mapping(target = "count", source = "roundCount")
  @Mapping(target = "id", ignore = true)
  RoomCardPlayerRoundCountDomain toRoomCardPlayerRoundCountDomain(PlayerBo bo);

  @Mapping(target = "playerId", source = "id")
  @Mapping(target = "id", ignore = true)
  PlayerGameInfoDomainWithBLOBs toPlayerGameInfoDomain(PlayerBo bo);

  @Mapping(target = "playerId", source = "id")
  @Mapping(target = "id", ignore = true)
  PlayerSafeInfoDomain toPlayerSafeInfoDomain(PlayerBo bo);

  @Mapping(target = "playerId", source = "id")
  @Mapping(target = "id", ignore = true)
  PlayerVipDomain toPlayerVipDomain(PlayerBo bo);

  @Mapping(target = "playerId", source = "id")
  @Mapping(target = "id", ignore = true)
  PlayerStatusRecordDomain toPlayerStatusRecordDomain(PlayerBo bo);

  @Mapping(target = "playerId", source = "id")
  PlayerRankBo toPlayerRankBo(PlayerMainDomain playerMainDomain);

  List<PlayerRankBo> toPlayerRankBos(List<PlayerMainDomain> playerMainDomains);
}
